<?php

if(!isset($_SESSION)) session_start();
if (!isset($_SESSION['f_user_id'])) {
	echo 'Access denied!';
} else {

	// data
	$o = f()->db()->find_by_pkey('appraisal','Appraisal',$param);
	if ($o === null) {
		echo 'Unknown classroom.';
	} else {
		$form = f()->form('add_appraisal','New appraisal')
			->text('name',t('Name'))
			->text('value',t('Value'))
			->image('image',t('Image'))
			->text('comment',t('Comment'),array(
				'rows' => 3,
			))
			->button('submit',t('Save'));
		$form->load($o);
		if ($form->submitted()) {
			$fields = array('name','value','image','comment');
			$form->save($o,$fields);
			$o->save();
			$student = f()->db()->find_by_pkey('student','Student',$o->student_id);
			$this->redirect('@classroom/'.$student->classroom_id);
		} else {
			$form->render();
		}
	}

}